package com.example.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
//@Aspect
//@Order(1)
//@Component
public class OrderAspect1 {

    /**
     * - `@Order` 数值 **越小优先级越高**
     */

    @Pointcut("execution(* com.example.service.impl.StudentServiceImpl.*(..))")
    public void callStudent() {
    }

    @Before("callStudent()")
    public void before() {
        log.info("OrderAspect1 before");
    }

    @After("callStudent()")
    public void after() {
        log.info("OrderAspect1 after");
    }

    @Around("callStudent()")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        log.info("OrderAspect1 around before");
        Object proceed = proceedingJoinPoint.proceed();
        log.info("OrderAspect1 around after");
        return proceed;
    }

}
